<template>
    <header class="header">
      <h1>todos</h1>
      <input class="new-todo" placeholder="请输入任务名称" autofocus v-model.trim="text" @keyup.enter="addList(text)"/>
    </header>
</template>

<script>
export default {
  name: 'TodoHeader',
  props: {},
  data(){
    return{
      text:''
    }
  },
  methods:{
    addList(text){
      if(!this.text) return
      //通知父组件添加
      this.$emit('addList',text)
      this.text=''
    }
  }
}
</script>

<style scoped lang="less"></style>
